package com.otomotion.research.ants.io;

import org.jdom.Element;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;

import com.otomotion.research.ants.information.Coordinate;


public class RequestFactory {
	
	static private int requestID = 0;

	static public String getData(Coordinate c, int radius)
	{
		
		Element request = new Element("Request");
		request.setAttribute("requestID",String.valueOf(requestID++));
		
		for (int i=c.getX()-radius;i<c.getX()+radius;i++)
		{
			for (int j = c.getY()-radius;j<c.getY()+radius;j++)
			{
				for (int k = c.getZ()-radius;k<c.getZ()+radius;k++)
				{
					Element e = new Element("c");
					e.setAttribute("x",String.valueOf(i));
					e.setAttribute("y",String.valueOf(j));
					e.setAttribute("z",String.valueOf(k));
					request.addContent(e);
				}
			}
		}
		
		
		XMLOutputter out = new XMLOutputter();
		out.setFormat(Format.getPrettyFormat());
		return out.outputString(request);
		
	}
}
